package table.creators;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import controllers.AuthorHelper;
import models.Driver_evaluation;
import models.Driver;
import controllers.Helper;
import controllers.TableModel;
import controllers.TableModel.AoColum;

public class Driver_evaluationTable {

    public static TableModel create(String current_user) {
    
        final String title = "司机评级";
        String today = Helper.dateToString(new Date());
        String now = Helper.datetimeToString(new Date());

        List<AoColum> colums = new ArrayList<AoColum>();
        TableModel model = new TableModel();

        //                           name,             title,         required,     defaut,        cansearch, editable,    edit_type,    edit_data,            editable_settings    
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("id",    "编号",    false,    "",    false,    false,    "edit",    null,    null,  "ONEBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("evaluation_date",    "考评日期",    true,    today,    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "date",    null,    null,  "ONEBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("driver.name",    "驾驶员姓名",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "select",    Driver.getNameJson(),    null,  "ONEBOX",  "driver",  "name",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("responsibility",    "签约责任书（20分）",    true,    "0",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "edit",    null,    null,  "TWOBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("common_violation",    "一般违章（10分）",    true,    "0",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "edit",    null,    null,  "TWOBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("bad_violation",    "严重违章（20分）",    true,    "0",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "edit",    null,    null,  "TWOBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("completion",    "例保完成（10分)",    true,    "0",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "edit",    null,    null,  "TWOBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("learning",    "参加学习（10分)",    true,    "0",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "edit",    null,    null,  "TWOBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("execution",    "作业执行（20分）",    true,    "0",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "edit",    null,    null,  "TWOBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("finish_receipe",    "衔接单证（10分)",    true,    "0",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "edit",    null,    null,  "TWOBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("total",    "总评分",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "#total",    null,    null,  "TWOBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("comments",    "评语",    true,    "",    false,    AuthorHelper.isInRoleGroup(current_user, "0"),    "edit",    null,    null,  "ONEBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        model.buildModel(Driver_evaluation.class, 600, title, AuthorHelper.canDo(current_user, title, "增加"), AuthorHelper.canDo(current_user, title, "搜索"), AuthorHelper.canDo(current_user, title, "删除"), colums);
        return model;
    }
}

